package com.github.kotvertolet.youtubejextractor.models.youtube.playerResponse;

import com.github.kotvertolet.youtubejextractor.models.newModels.PlayerErrorMessageRenderer;
import ohos.utils.Parcel;
import ohos.utils.Sequenceable;

import java.io.Serializable;

import static com.github.kotvertolet.youtubejextractor.utils.StringUtils.urlDecode;

public class Cipher implements Sequenceable,Serializable {

    private String s;
    private String sp;
    private String url;

    public static final Sequenceable.Producer<Cipher> CREATOR = new Sequenceable.Producer<Cipher>() {
        @Override
        public Cipher createFromParcel(Parcel parcel) {
            // Initialize an instance first, then do customized unmarshlling.
            Cipher cipher = new Cipher();
            cipher.unmarshalling(parcel);
            return cipher;
        }
    };

    public Cipher() {
        super();
    }

    public Cipher(String s, String sp, String url) {
        this.s = s;
        this.sp = sp;
        this.url = url;
    }

    public String getS() {
        return urlDecode(s);
    }

    public void setS(String s) {
        this.s = s;
    }

    public String getSp() {
        return sp;
    }

    public void setSp(String sp) {
        this.sp = sp;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public boolean marshalling(Parcel parcel) {
        parcel.writeString(this.s);
        parcel.writeString(this.sp);
        parcel.writeString(this.url);
        return true;
    }

    @Override
    public boolean unmarshalling(Parcel parcel) {
        this.s=parcel.readString();
        this.sp=parcel.readString();
        this.url=parcel.readString();
        return true;
    }
}
